package slice_func

import "fmt"

func SliceInit() {
	//1、 声明切片
	var s1 []int
	if s1 == nil {
		fmt.Println("切片为空")
	} else {
		fmt.Println("切片有值", s1)
	}
	//2、短声明
	s2 := []int{1, 2}
	fmt.Println("切片短声明：", s2)
	//3、make
	s3 := make([]int, 0)
	fmt.Println("切片make声明：", s3)
	//4、赋值初始化
	var s4 []int = make([]int, 0, 0)
	fmt.Println("切片赋值并初始化声明：", s4)
	//5、基于数组切片
	arr1 := [5]int{1, 2, 3, 4, 5}
	s5 := arr1[1:3]
	fmt.Println("基于数组切片：", s5)

}
